package com.sesxh.project.knowledge.router;

import java.util.Map;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.sesxh.frame.core.data.DataSet;
import com.sesxh.frame.web.controller.BaseController;
import com.sesxh.project.knowledge.biz.model.Scan;
import com.sesxh.project.knowledge.biz.service.IScanService;
@Controller 
@RequestMapping("/knowledge/scan")
public class ScanController implements BaseController {

	
	@Autowired
	private IScanService scanService;
	
    @RequestMapping(value="/loadScanDataSet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadScanDataSet(@RequestParam Map<String,Object> params){
	    DataSet dataSet=  scanService.loadScanDataSet(params);
	    return ajaxQuery("dataSet", dataSet);
    }
	
    @RequestMapping(value="/createScan", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public  @ResponseBody Object createScan(Scan scan){
		scanService.createScan(scan);
    	return ajaxDoneSuccess("数据操作成功 ");
    }
	
    @RequestMapping(value="/loadScan", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadScan(Long id){
		Optional<Scan> ops = scanService.loadScanById(id);
		return ajaxQuery("scan",ops);
    }
	
    @RequestMapping(value="/updateScan", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object updateScan(Scan scan){
		scanService.updateScan(scan);
		return ajaxDoneSuccess("数据操作成功 ");
    }
	
    @RequestMapping(value="/deleteScan", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object deleteScan(Long id){
		scanService.deleteScan(id);
		return ajaxDoneSuccess("数据操作成功 ");
    }

}